﻿//===============================================================================
// PostSharp Poco implementation for EntityFramework
//===============================================================================
// Copyright © Ruurd Boeke.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PostSharp.Extensibility;
using PostSharp.Laos.Weaver;

namespace EntityFrameworkContrib.PostSharp4EF.Weaver
{
    /// <summary>
    /// returns the correct weaver, always the edm weaver
    /// </summary>
    public class PocoEDMWeaverFactory : Task, ILaosAspectWeaverFactory
    {

        #region ILaosAspectWeaverFactory Members
        /// <summary>
        /// creates the weaver
        /// </summary>
        /// <param name="aspect">the EDMSubAspect that instantiated this factory</param>
        /// <returns>
        /// the weaver that will do the lowlever hardcore work
        /// </returns>
        public LaosAspectWeaver CreateAspectWeaver(PostSharp.Laos.ILaosAspect aspect)
        {
            if (aspect is EDMSubAspect)
            {
                EDMSubAspect edmAttributesAspect = (EDMSubAspect)aspect;
                return new PocoEDMWeaver(edmAttributesAspect.MetadataString, edmAttributesAspect.Provider);
            }

            return null;
        }

        #endregion
    }
}
